package com.aloda.ojjudge.listener;

import com.aloda.ojjudge.service.JudgeService;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author aloda
 * @Date 2025/5/3 16:37
 */
@Component
public class JudgeMessageListener {

    @Resource
    private JudgeService judgeService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "judge.task", durable = "true"),
            exchange = @Exchange(name = "judge.topic"),
            key = "judge.task"
    ))
    public void listenJudgeTask(Long questionSubmitId) {
        judgeService.doJudge(questionSubmitId);
    }
}